package com.lagou.pojo;

import java.util.Arrays;

/**
 * 2.给MappedStatement添加语句类型，根据不同的语句类型路由到不同的Executor方法来执行
 * @author leonzhangxf
 */
public enum StatementType {

    /**
     *
     */
    Select("select"),

    Insert("insert"),

    Update("update"),

    Delete("delete");

    public String getCode() {
        return code;
    }

    private final String code;

    StatementType(String code) {
        this.code = code;
    }

    public static StatementType getInstance(String code) {
        return Arrays.stream(StatementType.values())
            .filter(value -> value.getCode().equals(code))
            .findFirst().orElse(null);
    }
}
